/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection;

import authentication.AuthenticationData;
import authentication.EncryptionType;
import data.AccountData;
import data.Data;
import data.email.EmailFolder;
import data.email.AccountType;
import data.email.EmailMessage;
import javax.mail.Store;

/**
 * Třída zapouzdřující e-mailový účet pro odesílání, nebo přijímání. Umožňuje vytvořit účet.
 * @author Arcanis
 */
public abstract class Account {
    protected EncryptionType encryption = null;
    protected AccountType accountType = null;
    protected AuthenticationData authenticationData = null;
    protected String serverName = null;
    protected int port = 0;
    
    protected Account(AccountData data) {
        this.accountType = data.getType();
        this.authenticationData = new AuthenticationData(data.getLogin(), data.getPass());
        this.encryption = data.getEncryption();
        this.serverName = data.getServer();
        this.port = data.getPort();
    }
    
    public static Account createAccount(AccountData data) throws Exception {
        if(data.getType().equals(AccountType.IMAP)){
            return new IMAPAccount(data);
        }else if(data.getType().equals(AccountType.POP3)){
            return new Pop3Account(data);
        }else if (data.getType().equals(AccountType.SMTP)){
            return new SMTPAccount(data);
        }
        return null;
    }       
}
